<template>
  <page-header-wrapper>
    <div>
      <a-row :gutter="24">
        <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
          <!-- 项目简介 -->
          <a-card
            style="width:100%"
            title="店铺业绩总览"
          >
            <a-date-picker v-model="queryParam.date" @change="onChange" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD" />
            <!-- 数据展示 -->
            <a-table
              style="margin-top: 20px"
              :loading="loading"
              :size="tableSize"
              rowKey="menuId"
              :columns="columns"
              :data-source="list"
              :pagination="false"
              :bordered="tableBordered">
              <template slot="groupOneImage" slot-scope="text, record">
                <a-avatar :size="64" :src="text" shape="square"/>
              </template>
            </a-table>
          </a-card>
        </a-col>
      </a-row>
    </div>
  </page-header-wrapper>
</template>

<script>
import {mapState} from 'vuex'
import { PageHeaderWrapper } from '@/components/ProLayout'
import {getAllStoreData} from "@/api/menu";

export default {
  name: 'Index',
  components: {
    PageHeaderWrapper
  },
  data () {
    return {
      dateFormat: 'YYYY/MM/DD',
      list: [],
      loading: false,
      queryParam: {
        date: ''
      },
      columns: [
        {
          title: '店铺id',
          dataIndex: 'id',
          align: 'center',
          width: 80
        },
        {
          title: '店铺名称',
          dataIndex: 'storeName',
          ellipsis: true,
          align: 'center',
          width: 120
        },
        {
          title: '店铺图片',
          dataIndex: 'storeImg',
          scopedSlots: { customRender: 'groupOneImage' },
          ellipsis: true,
          align: 'center',
          width: 120
        },
        {
          title: '店长名称',
          dataIndex: 'storeLeader',
          ellipsis: true,
          align: 'center',
          width: 100
        },
        {
          title: '店长手机号',
          dataIndex: 'storeLeaderPhone',
          ellipsis: true,
          align: 'center',
          width: 120
        },
        {
          title: '店长头像',
          dataIndex: 'storeLeaderImg',
          ellipsis: true,
          align: 'center',
          scopedSlots: { customRender: 'groupOneImage' },
          width: 120
        },
        {
          title: '商品名称',
          dataIndex: 'groupOneName',
          ellipsis: true,
          align: 'center'
        },
        {
          title: '商品图片',
          dataIndex: 'groupOneImage',
          ellipsis: true,
          scopedSlots: { customRender: 'groupOneImage' },
          align: 'center',
          width: 120
        },
        {
          title: '今日业绩',
          dataIndex: 'buyAmount',
          ellipsis: true,
          align: 'center',
          width: 100
        },
        {
          title: '预计明日业绩',
          dataIndex: 'sellAmount',
          ellipsis: true,
          align: 'center',
          width: 120
        },
        {
          title: '预约时间',
          dataIndex: 'sellAmount',
          ellipsis: true,
          align: 'center',
          customRender: (text, record) => {
            return record.reservationStartDate + ' - ' + record.reservationEndDate
          },
          width: 140
        },
        {
          title: '抢购时间',
          dataIndex: 'sellAmount',
          ellipsis: true,
          align: 'center',
          customRender: (text, record) => {
            return record.saleStartDate + ' - ' + record.saleEndDate
          },
          width: 140
        },
        {
          title: '不交易时间',
          dataIndex: 'noPayDay',
          ellipsis: true,
          align: 'center'
        }
      ]
    }
  },
  computed: {
    ...mapState({
      tableBordered: state => state.app.tableBordered
    }),
    tableSize: {
      get () { return this.tableSize1 || this.$store.state.app.tableSize },
      set (value) {
        this.tableSize1 = value
      }
    }
  },
  created () {
    this.getList()
  },
  mounted () {
  },
  methods: {
    onChange(val) {
      console.log(val)
      this.getList()
    },
    getList () {
      this.loading = true
      getAllStoreData(this.queryParam).then(response => {
          this.list = response.data
          this.loading = false
        }
      )
    }
  }
}
</script>

<style lang="less" scoped>
@import "./index.less";
blockquote {
  padding: 0 1em;
  color: #6a737d;
  border-left: 0.25em solid #dfe2e5;
}
.project-list {

  .card-title {
    font-size: 0;

    a {
      color: rgba(0, 0, 0, 0.85);
      margin-left: 12px;
      line-height: 24px;
      height: 24px;
      display: inline-block;
      vertical-align: top;
      font-size: 14px;

      &:hover {
        color: #1890ff;
      }
    }
  }

  .card-description {
    color: rgba(0, 0, 0, 0.45);
    height: 66px;
    line-height: 22px;
    overflow: hidden;
  }

  .project-item {
    display: flex;
    margin-top: 8px;
    overflow: hidden;
    font-size: 12px;
    height: 20px;
    line-height: 20px;

    a {
      color: rgba(0, 0, 0, 0.45);
      display: inline-block;
      flex: 1 1 0;

      &:hover {
        color: #1890ff;
      }
    }

    .download {
      color: rgba(0, 0, 0, 0.25);
      flex: 0 0 auto;
      float: right;
    }
  }

  .ant-card-meta-description {
    color: rgba(0, 0, 0, 0.45);
    height: 44px;
    line-height: 22px;
    overflow: hidden;
  }
}

.item-group {
  padding: 20px 0 8px 24px;
  font-size: 0;

  a {
    color: rgba(0, 0, 0, 0.65);
    display: inline-block;
    font-size: 14px;
    margin-bottom: 13px;
    width: 25%;
  }
}

.mobile {

  .project-list {

    .project-card-grid {
      width: 100%;
    }
  }

  .more-info {
    border: 0;
    padding-top: 16px;
    margin: 16px 0 16px;
  }

  .headerContent .title .welcome-text {
    display: none;
  }
}

</style>
